Repository navigation
fix(inference): report provider errors and cut-off cloud chat streams - #355
Merged
ganisback merged 1 commit intoNov 28, 2026
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an OpenAI-compatible provider answers 200 and then fails mid-stream,
Chatreturns the partial text with a nil error, so a truncated answer looks complete.Cause:
openAIEngine.handleStreamWithCacheUsageskipsdata: {"error": ...}events (they have no choices) and does not check that the stream actually finished before returningscanner.Err().Fix:
errorpayload (object or string) is returned as an error carrying the provider's message;[DONE]nor afinish_reasonreturnsio.ErrUnexpectedEOF, as the llama engine already does for a missing[DONE];finish_reasonwithout[DONE]is still accepted, and an open<think>block is closed in that case too;data:events behave as before.This affects callers of
Chat(for example/api/chatwith a cloud or third-party model). The raw/v1/chat/completionsproxy path does not go through this code.Tests: new cases in
internal/inference/openai_stream_error_test.gofail without the change and pass with it.go test ./internal/inference/passes, as do the chat, provider and gateway related tests ininternal/server.This change was prepared with AI assistance.